home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Source Code ƒ / MPW C ƒ / SonOfGrepƒ / Grep-MJS.h < prev    next >
Encoding:
Text File  |  1990-01-20  |  3.8 KB  |  82 lines  |  [TEXT/MPS ]

  1. /* MJS: 
  2.  
  3.         This is a second upload of SonOfGrep for MPW.  The first one was lost
  4.     when MAUG was reorganized in November 89.  Slight changes from the 
  5.     previous version include a spinning cursor.
  6.     
  7.         Welcome to Son of Grep.  As far as I can tell, this is a public
  8.     domain version of UNIX Grep.  I found it on GEnie.  It was uploaded by
  9.     John Pence, whose GEnie mail ID is MACMAN.  He failed to reply to my notes
  10.     requesting his explicit permission to re-use the source files, but 
  11.     there's nothing in the files to indicate he reserved any rights to them.
  12.  
  13.         It appears that the source of the source (so to speak) was an article
  14.     in Dr. Dobbs Journal, but no copyright notice appears in the code, so
  15.     I'm assuming John wrote most of it from scratch.
  16.     
  17.         It also appears that John's version was originally compiled using
  18.     Consulair Mac C.  One of the source files I omitted contained glue to
  19.     simulate a command-line interface for the program, and without that glue,
  20.     the rest of the code looked to me like it would compile just fine in a 
  21.     UNIX-like environment.  As a matter of fact, it did.  I made minimal 
  22.     adjustments to make it compatible with MPW C, and each of those adjustments
  23.     is clearly indicated by a comment with my initials.
  24.  
  25.         I've used this little Grep tool extensively, but I haven't tried all of
  26.     its options yet.  As such, it's relatively untested.  Use at your own
  27.     risk, I guess, although I'm pretty confident it all works.  
  28.     
  29.         I recommend you make Grep an alias for SonOfGrep.  Here's a tiny script 
  30.     useful for grep'ing all files in a folder:
  31.                 SonOfGrep {Parameters} `files -t TEXT`
  32.     
  33.     Send comments to me, Matthew Snyder, CIS 71450,2606.
  34.     
  35.     Here is the file description associated with the original upload on GEnie...
  36.     
  37.  * This is the example from Alan Holubs October 1984 Grep article. Newcomers
  38.  * to grepping will find the article most helpful, as this application has
  39.  * very little in the way of interface. Greps one file at a time, uses syntax
  40.  * as described in the article. Converted to run in Consulair Mac C. Source
  41.  * in Grep.c and tools.c Enjoy- John Pence
  42.  
  43.     Here is usage information, gleamed from other sources (fgrep) but probably
  44.     pretty accurate...
  45.  
  46.  * USAGE:  fgrep [-?vclnhyef] [strings] <files>
  47.  *
  48.  * where:
  49.  *
  50.  *    -v    All lines but those matching are printed.
  51.  *    -c    Only a count of the matching lines is printed.
  52.  *    -l    The names of the files with matching lines are listed
  53.  *        (once), separated by newlines.
  54.  *    -n    Each line is preceded by its line number in the file.
  55.  *    -h    Do not print filename headers with output lines.
  56.  *    -y    All characters in the file are mapped to upper case
  57.  *        before matching.  (This is the default if the string
  58.  *        is given in the command line under CP/M, as CP/M
  59.  *        maps everything on the command line to upper case.
  60.  *        Use the -f option if you need both lower and upper
  61.  *        case).  Not a true UNIX "fgrep" option (normally
  62.  *        available under "grep" only), but too useful to leave out.
  63.  *    -e    <string>.  Same as a string argument, but useful
  64.  *        when the string begins with a '-'.
  65.  *    -f    <file>. The strings (separated by newlines) are taken
  66.  *        from a file.  If several strings are listed in the
  67.  *        file, then a match is flagged if any of the strings
  68.  *        are matched.  If -f is given, any following argument
  69.  *        on the command line is taken to be a filename.
  70.  
  71.         A note on usage:  Unlike most MPW tools, this one requires that the 
  72.     options be passed in order.  In addition, only one hyphen is needed.
  73.     For example, if you want line numbers and you want all lines EXCEPT
  74.     those containing matches to be printed, you would type
  75.             SonOfGrep -nv string filename(s)
  76.     "SonOfGrep -vn" would not work, and neither would "SonOfGrep -n -v."
  77.  
  78. *****************************************************************************/
  79.  
  80. /* MJS: OSreset normally called before abort, apparently leftover from CP/M */
  81. OSreset() { printf("# %s almost done...  ", ToolName()); };
  82.